<template>
	<view class="banben">
		<view class="body">
			<view class="list" v-for="(item,index) in list" :key="index">
				<view class="top clearfix">
					<view class="left fl">版本号：{{item.banben}}</view>
					<view class="right fr" @click="copy(index)">复制下载链接</view>
				</view>
				<view class="center">
					<view class="dizhi">{{item.description}}</view>
				</view>
				<view class="bottom clearfix">
					<text>{{item.create_time}}</text>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		request
	} from '@/api/request';

	export default {
		data() {
			return {
				list: [],
			}
		},
		onLoad() {
			request({
				url: '/api/main/version',
				method: 'GET',
				data: {},
				header: {
					'xx-token': uni.getStorageSync('token')
				}
			})
			.then((response) => {
				this.list = response.data;
			})
			.catch((error) => {});
		},
		methods: {
			copy(index){
				let url = this.list[index].url;
				
				uni.setClipboardData({
					data: url,
					success: () => {
						uni.showToast({
							title: '复制成功,请在浏览器打开',
							icon: 'none'
						});
					},
					fail: () => {
						uni.showToast({
							title: '复制失败',
							icon: 'none'
						});
					}
				});
			}
		}
	}
</script>

<style scoped lang="scss">
	.banben {
		width: 100%;
		margin: 0 auto;
		
		.body{
			width: 94%;
			margin: 20rpx auto;
			
			.list{
				width: 100%;
				margin: 0 auto 20rpx;
				background: #242831;
				box-sizing: border-box;
				border-radius: 20rpx;
				position: relative;
				
				.top{
					width: 94%;
					margin: 0 auto;
					padding-top: 24rpx;
					padding-bottom: 26rpx;
					border-bottom: 1rpx solid #31353E;
					box-sizing: border-box;
					
					.left{
						font-size: 30rpx;
						color: #FFFFFF;
						width: 58%;
						white-space: nowrap; /* 设置文本不换行 */
						overflow: hidden; /* 隐藏溢出的内容 */
						text-overflow: ellipsis; /* 将溢出的文本显示为省略号 */
					}
					
					.right{
						width: 40%;
						font-size: 30rpx;
						color: #ECDEA4;
						text-align: right;
					}
				}
				
				.center{
					width: 94%;
					margin: 0 auto;
					margin-top: 20rpx;
					
					.dizhi{
						width: 100%;
						color: #ABB0CC;
						font-size: 26rpx;
						line-height: 36rpx;
					}
				}
				
				.bottom{
					width: 94%;
					margin: 0 auto;
					padding: 0 0 3%;
					margin-top: 20rpx;
					
					text{
						float: right;
						color: #787B8F;
						font-size: 24rpx;
					}
				}
			}
		}
	}
</style>